package com.questionnaire.controller;

import com.questionnaire.entity.Question;


import com.questionnaire.entity.Questionnaire;
import com.questionnaire.service.QuestionService;
import com.questionnaire.service.QuestionnaireService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;

import org.springframework.web.bind.annotation.RequestMapping;



@Controller
public class QuestionController {
    @Autowired
    private QuestionService questionService;
    @Autowired
    private QuestionnaireService questionnaireService;

    //创建问题
    @RequestMapping("/found_question.do")
    public String  found_naire(ModelMap map,Question question){
        Questionnaire questionnaire=questionnaireService.selectByPrimaryKey(question.getOwnerquestionnaireid());

        questionService.insert(question);
        int  questioncode =question.getQuestioncode()+1;
        map.put("questionnaire",questionnaire);
         map.put("questioncode",questioncode);
        return "found_question";
    }
}
